package org.csu.mypetstore.persistence.impl;

import org.csu.mypetstore.persistence.DBUtill;
import org.csu.mypetstore.persistence.LogDAO;

import java.sql.Connection;
import java.sql.PreparedStatement;



public class LogDAOImpl implements LogDAO {

    public static final String INSERT_LOG = "INSERT INTO LOG (TITLE, CONTENT, USERNAME) VALUES (?, ?, ?)";

    @Override
    public void insertLog(String title, String content, String username) {
        try {
            Connection connection = DBUtill.getConnection();
            PreparedStatement pStatement = connection.prepareStatement(INSERT_LOG);
            pStatement.setString(1, title);
            pStatement.setString(2, content);
            pStatement.setString(3, username);
            pStatement.executeUpdate();
            DBUtill.closePreparedStatement(pStatement);
            DBUtill.closeConnection(connection);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
